# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=libasr
pkgver=1.0.4
pkgrel=2
pkgdesc="libasr is a free, simple and portable asynchronous resolver library"
url="https://www.opensmtpd.org"
arch="all"
license="ISC"
makedepends="mandoc bison openssl1.1-compat-dev automake autoconf libtool libbsd-dev"
subpackages="$pkgname-dbg $pkgname-static $pkgname-dev"
source="https://github.com/OpenSMTPD/libasr/archive/$pkgver/libasr-$pkgver.tar.gz
	0002-Replace-missing-res_randomid-with-the-more-secure-ar.patch
	"

prepare() {
	default_prepare
	./bootstrap
}

check() {
	gcc -L src/.libs -I src tests/asr_simple.c -lasr -o tests/asr_simple
	LD_LIBRARY_PATH=src/.libs ./tests/asr_simple
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="93ff4643c46cccb36e4981336dde198975499c1e48df6ed0fa8e57628ea05a8dc1d5159fe9d0ee99ff2e7ab418aa346668749aca8be2f3346f07d884e4818368  libasr-1.0.4.tar.gz
693c2bfce2ca9397909a281b3d634b37608ff6286a4e9b3c1d638a337c585d307db4a325fb8b607ef45399c1ee05063eda5eb46060d804e5b4ad51ca6890846d  0002-Replace-missing-res_randomid-with-the-more-secure-ar.patch"
